package scau.zhong.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import scau.zhong.pojo.Permission;
import scau.zhong.pojo.Role;
import scau.zhong.pojo.User;

import java.util.List;

@FeignClient(value = "user")
public interface UserService extends UserDetailsService {

    @RequestMapping(value = "/user/all",method = RequestMethod.GET)
    List<User> findAll();

    /**
     * 根据用户ID查询用户角色
     * @param id
     * @return
     */
    @RequestMapping(value = "/user/roles",method = RequestMethod.GET)
    List<Role> queryRoleById(String id);

    /**
     * 根据用户ID查询用户权限
     * @param id
     * @return
     */
    @RequestMapping(value = "/user/permissions",method = RequestMethod.GET)
    List<Permission> queryPermissionByUID(String id);

    /**
     * 注册普通用户
     * @param user
     */
    int insertUser(@RequestBody User user);

    /**
     * 注册管理员用户
     * @param user
     * @return
     */
    int insertAdmin(@RequestBody User user);

    /**
     * 根据email查询某用户是否存在
     * @param email
     * @return
     */
    boolean isUserExit(String email);
}
